<?php
/**
 * Created by PhpStorm.
 * 人员管理M 
 */

namespace app\api\model;
use think\Model;
use think\Db;

class Companyuser extends Model
{

    // 表名发发发
    public $name = 'company_user';
    /**
     * 插入数据
     * @param $data
     * @return bool|int|string
     */
    public function insertData($data)
    {
        $r = $this->insertGetId($data);
        if(!$r){
            return false;
        }

        return $r;
    }

    /**
     * 编辑数据
     * @param $data
     * @param $where
     * @return Project
     */
    public function updateBywhere($data,$where){
        $r = $this->where($where)->update($data);
        return $r;
    }

    /**
     * 获取总数
     * @param array $where
     * @return int|string
     * @throws \think\Exception
     */
    public function countWhere($where = []){
        $r = $this->where($where)->count();
        return $r;
    }

    /**
     * 假删
     * @param array $where
     * @return Project
     */
    public function deleteWhere($where = []){
        $r = $this->where($where)->update(['is_delete'=>1]);
        return $r;
    }

    /**
     * 获取详情
     * @param array $where
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function findWhere($where = []){
       
        $r = $this->where($where)->find();
        return $r;
    }

    /**
     * 分页列表
     * @param array $where
     * @param string $order
     * @param int $current
     * @param int $pagesize
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function listWherePage($where = [],$order = 'id desc',$current = 0,$pagesize = 10){
        $r = $this->where($where)->order($order)->limit($current.','.$pagesize)->select();
        return $r;
    }

        /**
     * 所有列表
     * @param array $where
     * @param string $order
     * @param int $current
     * @param int $pagesize
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function listAll($where = [],$order = 'id desc',$current = 0,$pagesize = 10){
        $r = $this->where($where)
                  ->order($order)
                  ->select();
        return $r;
    }

     //企业设置  执行新增
    public function insertDataf1($data)
    {        
        $this->name = 'companyf1';
       // $r = $this->insertGetId($data);
       $r = Db::name('companyf1')->insertGetId($data);
       var_dump($r);die;
        if(!$r){
            return false;
        }
        return $r;         
    }


         //企业设置  执行新增 测试
         public function selt1($data)
         {        
            $exam_info= Db::name('admin')
            //->alias('a')
           // ->leftJoin('word w','a.id = w.artist_id')
            ->select();     
            return $exam_info;   
         }
    //企业设置  测试
     public function inset1($data)
        {        
             
            $data1['account']="222";
            $r = Db::name('admin')->insertGetId($data1);
            if(!$r){
                return false;
            }
            return $r;   
              
        }
     




}